//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing
{
    public class StyleMatrixReference : IOfficeXmlSerializableAs
    {
        private ColorBase color;
        private int idx;

        public int Index
        {
            get { return idx; }
            set { idx = value; }
        }

        public ColorBase Color
        {
            get { return color; }
            set { color = value; }
        }

        #region IOfficeXmlSerializableAs Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.ReadAndSwitch(name, DrawingConstants.DrawingNamespaceUri, context.ForceNamespace))
            {
                Index = c.GetInteger("idx");
                Color = ColorBase.ReadColor(c);
            }
        }

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.WriteAndSwitch(name, DrawingConstants.DrawingNamespace))
            {
                c.SetInteger("idx", Index);
                c.WriteElement(Color);
            }
        }

        #endregion

        /* Brush brush;
        public Brush Brush
        {
            get
            {
                if (brush == null)
                    brush = Color.Brush;
                return brush;
            }
        }*/
    }
}